In [1]:
import requests
from bs4 import BeautifulSoup
import pandas as pd
import json
In [2]:
prefix = "https://kooplex-edu.elte.hu/notebook/dvtulf-dataexplvisu/report"

def flatten(a):
    return [item for sublist in a for item in sublist]

1) /help endpoint

In [3]:
#Status message
endpoint = "/help"
resp_obj = requests.get(prefix + endpoint)
In [4]:
#Content
BeautifulSoup(resp_obj.content, "html.parser")
Out[4]:
<h2>HELP</h2><p>About the dataset: it is the World Bank's 2015 World Development Indicators dataset, which was modified by removing some missing data based on some criteria (can be viewed in the notebook).</p><h4>GET /info</h4><p>Description: Retrieve the list of available <em>series_code </em>in json format along with the meaning of every code.</p><h4>GET /api/data</h4><p>Description: Retrieves either all the data (if no <em>args</em> given), or a subdataframe of the data for the specific:</p><ul><li><em>country </em>(or multiple countries),</li><li><em>series_code </em>(or multiple series codes),</li><li><em>country</em> AND<em> series code</em> (OR multiple countries AND multiple series codes).</li></ul><p> Requires:</p><ul><li><em>country</em> (str) (optional)</li><li><em>series_code</em> (str) (optional)</li></ul><p>Returns:</p><ul><li>subdataframe (HTML)</li></ul><p>Example query: /api/data?country=Hungary&amp;country=Algeria&amp;country=Belgium&amp;series_code=AGPRDLVSKXD&amp;series_code=EGELCRNEWZS</p><h4>POST /api/data/</h4><p>Description: Adds extra data point into the dataset for the given one <strong>new</strong> <em>country</em> to the given (multiple) <strong>existing</strong> <em>series_code.</em></p><p><strong>Warning: </strong>if not every <em>series_code</em>s is given, then the PCA and the t-SNE algorithm works on imputed average data.</p><ul><li><em>series_code</em>(str)</li><li><em>country</em> (str)</li><li><em>value</em> (float)</li></ul><p>Returns:</p><ul><li>Status 200: Upload successful.</li></ul><p>Example query: /api/data?series_code=AGPRDLVSKXD&amp;country=Azmenistan&amp;value=1.372</p><h4>PUT /data/</h4><p>Description: Replaces an existing data point in the dataset for the given <em>series_code</em> for the given <em>country </em>with the given <em>value,</em> or multiple <em>series_code</em>s for multiple <em>value</em>s .</p><p>Requires:</p><ul><li><em>country</em> (str)</li><li><em>value</em> (float)</li><li><em>series_code </em>(str)</li></ul><p>Returns:</p><ul><li>Status 200: Edit successful.</li></ul><p>Example query: /api/data?country=Belgium&amp;value=3.9152&amp;series_code=AGPRDLVSKXD</p><p> </p><p><strong>GET /api/tsne</strong></p><p>Description: Plotting the data using t-distributed stochastic neighbour embedding (<strong>t-SNE</strong>). t-SNE is a method for visualizing high-dimensional data in lower dimensions. Countries can be highlighted manually by giving keyword arguments. Hungary is highlighted as default.</p><p>Requires:</p><ul><li><em>country </em>(str)(optional) (or multiple countries) - these countries will be highlighted on the plot.</li></ul><p> </p><p><strong>GET /api/pca</strong></p><p>Description: Calculates the principal components of the scaled data and shows the first 3 plotted against each other on an interactive graph. Hungary and Norway are highlighted.</p><p>Requires:</p><ul><li>None</li></ul><p>Rettrns:</p><ul><li>The first three principal components plotted against each other with each points labeled by the associated country.</li></ul>

2) /info endpoint: with json output

In [5]:
endpoint = "/info"
#Status message
resp_obj = requests.get(prefix + endpoint)
In [6]:
#Content
BeautifulSoup(resp_obj.content, "html.parser")
Out[6]:
{"AGLNDAGRIK2": "Agricultural land (sq. km)", "AGLNDAGRIZS": "Agricultural land (% of land area)", "AGLNDARBLHA": "Arable land (hectares)", "AGLNDARBLHAPC": "Arable land (hectares per person)", "AGLNDARBLZS": "Arable land (% of land area)", "AGLNDCROPZS": "Permanent cropland (% of land area)", "AGLNDFRSTK2": "Forest area (sq. km)", "AGLNDFRSTZS": "Forest area (% of land area)", "AGLNDTOTLK2": "Land area (sq. km)", "AGPRDCROPXD": "Crop production index (2004-2006 = 100)", "AGPRDFOODXD": "Food production index (2004-2006 = 100)", "AGPRDLVSKXD": "Livestock production index (2004-2006 = 100)", "AGSRFTOTLK2": "Surface area (sq. km)", "BXKLTDINVCDWD": "Foreign direct investment, net inflows (BoP, current US$)", "EGEGYPRIMPPKD": "Energy intensity level of primary energy (MJ/$2011 PPP GDP)", "EGELCACCSRUZS": "Access to electricity, rural (% of rural population)", "EGELCACCSURZS": "Access to electricity, urban (% of urban population)", "EGELCACCSZS": "Access to electricity (% of population)", "EGELCRNEWZS": "Renewable electricity output (% of total electricity output)", "EGFECRNEWZS": "Renewable energy consumption (% of total final energy consumption)", "ENATMCO2EGFKT": "CO2 emissions from gaseous fuel consumption (kt)", "ENATMCO2EGFZS": "CO2 emissions from gaseous fuel consumption (% of total)", "ENATMCO2EKT": "CO2 emissions (kt)", "ENATMCO2ELFKT": "CO2 emissions from liquid fuel consumption (kt)", "ENATMCO2ELFZS": "CO2 emissions from liquid fuel consumption (% of total)", "ENATMCO2EPC": "CO2 emissions (metric tons per capita)", "ENATMCO2ESFKT": "CO2 emissions from solid fuel consumption (kt)", "ENATMCO2ESFZS": "CO2 emissions from solid fuel consumption (% of total)", "ENATMPM25MCM3": "PM2.5 air pollution, mean annual exposure (micrograms per cubic meter)", "ENATMPM25MCT1ZS": "PM2.5 pollution, population exposed to levels exceeding WHO Interim Target-1 value (% of total)", "ENATMPM25MCT2ZS": "PM2.5 pollution, population exposed to levels exceeding WHO Interim Target-2 value (% of total)", "ENATMPM25MCT3ZS": "PM2.5 pollution, population exposed to levels exceeding WHO Interim Target-3 value (% of total)", "ENATMPM25MCZS": "PM2.5 air pollution, population exposed to levels exceeding WHO guideline value (% of total)", "ENPOPDNST": "Population density (people per sq. km of land area)", "ERFSHCAPTMT": "Capture fisheries production (metric tons)", "ERFSHPRODMT": "Total fisheries production (metric tons)", "IPJRNARTCSC": "Scientific and technical journal articles", "ITCELSETS": "Mobile cellular subscriptions", "ITCELSETSP2": "Mobile cellular subscriptions (per 100 people)", "ITMLTMAIN": "Fixed telephone subscriptions", "ITMLTMAINP2": "Fixed telephone subscriptions (per 100 people)", "ITNETBBND": "Fixed broadband subscriptions", "ITNETBBNDP2": "Fixed broadband subscriptions (per 100 people)", "ITNETSECR": "Secure Internet servers", "ITNETSECRP6": "Secure Internet servers (per 1 million people)", "ITNETUSERZS": "Individuals using the Internet (% of population)", "NEEXPGNFSCD": "Exports of goods and services (current US$)", "NEEXPGNFSCN": "Exports of goods and services (current LCU)", "NEEXPGNFSZS": "Exports of goods and services (% of GDP)", "NEIMPGNFSCD": "Imports of goods and services (current US$)", "NEIMPGNFSCN": "Imports of goods and services (current LCU)", "NEIMPGNFSZS": "Imports of goods and services (% of GDP)", "NERSBGNFSCD": "External balance on goods and services (current US$)", "NERSBGNFSCN": "External balance on goods and services (current LCU)", "NERSBGNFSZS": "External balance on goods and services (% of GDP)", "NETRDGNFSZS": "Trade (% of GDP)", "NVAGRTOTLCD": "Agriculture, forestry, and fishing, value added (current US$)", "NVAGRTOTLCN": "Agriculture, forestry, and fishing, value added (current LCU)", "NVAGRTOTLZS": "Agriculture, forestry, and fishing, value added (% of GDP)", "NVINDTOTLCD": "Industry (including construction), value added (current US$)", "NVINDTOTLCN": "Industry (including construction), value added (current LCU)", "NVINDTOTLZS": "Industry (including construction), value added (% of GDP)", "NVSRVTOTLCN": "Services, value added (current LCU)", "NVSRVTOTLZS": "Services, value added (% of GDP)", "NYADJAEDUGNZS": "Adjusted savings: education expenditure (% of GNI)", "NYADJDCO2CD": "Adjusted savings: carbon dioxide damage (current US$)", "NYADJDCO2GNZS": "Adjusted savings: carbon dioxide damage (% of GNI)", "NYADJDKAPCD": "Adjusted savings: consumption of fixed capital (current US$)", "NYADJDKAPGNZS": "Adjusted savings: consumption of fixed capital (% of GNI)", "NYADJDMINCD": "Adjusted savings: mineral depletion (current US$)", "NYADJDMINGNZS": "Adjusted savings: mineral depletion (% of GNI)", "NYADJDNGYCD": "Adjusted savings: energy depletion (current US$)", "NYADJDNGYGNZS": "Adjusted savings: energy depletion (% of GNI)", "NYGDPDEFLKDZG": "Inflation, GDP deflator (annual %)", "NYGDPDEFLKDZGAD": "Inflation, GDP deflator: linked series (annual %)", "NYGDPDEFLZS": "GDP deflator (base year varies by country)", "NYGDPDEFLZSAD": "GDP deflator: linked series (base year varies by country)", "NYGDPFRSTRTZS": "Forest rents (% of GDP)", "NYGDPMINRRTZS": "Mineral rents (% of GDP)", "NYGDPMKTPCD": "GDP (current US$)", "NYGDPMKTPCN": "GDP (current LCU)", "NYGDPMKTPCNAD": "GDP: linked series (current LCU)", "NYGDPMKTPKD": "GDP (constant 2010 US$)", "NYGDPMKTPKDZG": "GDP growth (annual %)", "NYGDPMKTPKN": "GDP (constant LCU)", "NYGDPMKTPPPCD": "GDP, PPP (current international $)", "NYGDPMKTPPPKD": "GDP, PPP (constant 2017 international $)", "NYGDPNGASRTZS": "Natural gas rents (% of GDP)", "NYGDPPCAPCD": "GDP per capita (current US$)", "NYGDPPCAPCN": "GDP per capita (current LCU)", "NYGDPPCAPKD": "GDP per capita (constant 2010 US$)", "NYGDPPCAPKDZG": "GDP per capita growth (annual %)", "NYGDPPCAPKN": "GDP per capita (constant LCU)", "NYGDPPCAPPPCD": "GDP per capita, PPP (current international $)", "NYGDPPCAPPPKD": "GDP per capita, PPP (constant 2017 international $)", "NYGDPPETRRTZS": "Oil rents (% of GDP)", "NYGDPTOTLRTZS": "Total natural resources rents (% of GDP)", "NYGNPATLSCD": "GNI, Atlas method (current US$)", "NYGNPMKTPCD": "GNI (current US$)", "NYGNPMKTPCN": "GNI (current LCU)", "NYGNPMKTPCNAD": "GNI: linked series (current LCU)", "NYGNPMKTPPPCD": "GNI, PPP (current international $)", "NYGNPPCAPCD": "GNI per capita, Atlas method (current US$)", "NYGNPPCAPCN": "GNI per capita (current LCU)", "NYGNPPCAPPPCD": "GNI per capita, PPP (current international $)", "NYGSRNFCYCD": "Net primary income (Net income from abroad) (current US$)", "NYGSRNFCYCN": "Net primary income (Net income from abroad) (current LCU)", "PANUSATLS": "DEC alternative conversion factor (LCU per US$)", "PANUSPPP": "PPP conversion factor, GDP (LCU per international $)", "PANUSPPPCRF": "Price level ratio of PPP conversion factor (GDP) to market exchange rate", "PANUSPRVTPP": "PPP conversion factor, private consumption (LCU per international $)", "SECOMDURS": "Compulsory education, duration (years)", "SEPREDURS": "Preprimary education, duration (years)", "SEPRMAGES": "Primary school starting age (years)", "SEPRMDURS": "Primary education, duration (years)", "SESECAGES": "Lower secondary school starting age (years)", "SESECDURS": "Secondary education, duration (years)", "SHH2OBASWZS": "People using at least basic drinking water services (% of population)", "SHSTABASSZS": "People using at least basic sanitation services (% of population)", "SHSTAODFCZS": "People practicing open defecation (% of population)", "SHTBSDTECZS": "Tuberculosis case detection rate (%, all forms)", "SHTBSINCD": "Incidence of tuberculosis (per 100,000 people)", "SMPOPTOTL": "International migrant stock, total", "SMPOPTOTLZS": "International migrant stock (% of population)", "SPADOTFRT": "Adolescent fertility rate (births per 1,000 women ages 15-19)", "SPDYNCBRTIN": "Birth rate, crude (per 1,000 people)", "SPDYNCDRTIN": "Death rate, crude (per 1,000 people)", "SPDYNLE00FEIN": "Life expectancy at birth, female (years)", "SPDYNLE00IN": "Life expectancy at birth, total (years)", "SPDYNLE00MAIN": "Life expectancy at birth, male (years)", "SPDYNTFRTIN": "Fertility rate, total (births per woman)", "SPDYNTO65FEZS": "Survival to age 65, female (% of cohort)", "SPDYNTO65MAZS": "Survival to age 65, male (% of cohort)", "SPPOP0004FE5Y": "Population ages 00-04, female (% of female population)", "SPPOP0004MA5Y": "Population ages 00-04, male (% of male population)", "SPPOP0014FEIN": "Population ages 0-14, female", "SPPOP0014FEZS": "Population ages 0-14, female (% of female population)", "SPPOP0014MAIN": "Population ages 0-14, male", "SPPOP0014MAZS": "Population ages 0-14, male (% of male population)", "SPPOP0014TO": "Population ages 0-14, total", "SPPOP0014TOZS": "Population ages 0-14 (% of total population)", "SPPOP0509FE5Y": "Population ages 05-09, female (% of female population)", "SPPOP0509MA5Y": "Population ages 05-09, male (% of male population)", "SPPOP1014FE5Y": "Population ages 10-14, female (% of female population)", "SPPOP1014MA5Y": "Population ages 10-14, male (% of male population)", "SPPOP1519FE5Y": "Population ages 15-19, female (% of female population)", "SPPOP1519MA5Y": "Population ages 15-19, male (% of male population)", "SPPOP1564FEIN": "Population ages 15-64, female", "SPPOP1564FEZS": "Population ages 15-64, female (% of female population)", "SPPOP1564MAIN": "Population ages 15-64, male", "SPPOP1564MAZS": "Population ages 15-64, male (% of male population)", "SPPOP1564TO": "Population ages 15-64, total", "SPPOP1564TOZS": "Population ages 15-64 (% of total population)", "SPPOP2024FE5Y": "Population ages 20-24, female (% of female population)", "SPPOP2024MA5Y": "Population ages 20-24, male (% of male population)", "SPPOP2529FE5Y": "Population ages 25-29, female (% of female population)", "SPPOP2529MA5Y": "Population ages 25-29, male (% of male population)", "SPPOP3034FE5Y": "Population ages 30-34, female (% of female population)", "SPPOP3034MA5Y": "Population ages 30-34, male (% of male population)", "SPPOP3539FE5Y": "Population ages 35-39, female (% of female population)", "SPPOP3539MA5Y": "Population ages 35-39, male (% of male population)", "SPPOP4044FE5Y": "Population ages 40-44, female (% of female population)", "SPPOP4044MA5Y": "Population ages 40-44, male (% of male population)", "SPPOP4549FE5Y": "Population ages 45-49, female (% of female population)", "SPPOP4549MA5Y": "Population ages 45-49, male (% of male population)", "SPPOP5054FE5Y": "Population ages 50-54, female (% of female population)", "SPPOP5054MA5Y": "Population ages 50-54, male (% of male population)", "SPPOP5559FE5Y": "Population ages 55-59, female (% of female population)", "SPPOP5559MA5Y": "Population ages 55-59, male (% of male population)", "SPPOP6064FE5Y": "Population ages 60-64, female (% of female population)", "SPPOP6064MA5Y": "Population ages 60-64, male (% of male population)", "SPPOP6569FE5Y": "Population ages 65-69, female (% of female population)", "SPPOP6569MA5Y": "Population ages 65-69, male (% of male population)", "SPPOP65UPFEIN": "Population ages 65 and above, female", "SPPOP65UPFEZS": "Population ages 65 and above, female (% of female population)", "SPPOP65UPMAIN": "Population ages 65 and above, male", "SPPOP65UPMAZS": "Population ages 65 and above, male (% of male population)", "SPPOP65UPTO": "Population ages 65 and above, total", "SPPOP65UPTOZS": "Population ages 65 and above (% of total population)", "SPPOP7074FE5Y": "Population ages 70-74, female (% of female population)", "SPPOP7074MA5Y": "Population ages 70-74, male (% of male population)", "SPPOP7579FE5Y": "Population ages 75-79, female (% of female population)", "SPPOP7579MA5Y": "Population ages 75-79, male (% of male population)", "SPPOP80UPFE5Y": "Population ages 80 and above, female (% of female population)", "SPPOP80UPMA5Y": "Population ages 80 and above, male (% of male population)", "SPPOPBRTHMF": "Sex ratio at birth (male births per female births)", "SPPOPDPND": "Age dependency ratio (% of working-age population)", "SPPOPDPNDOL": "Age dependency ratio, old (% of working-age population)", "SPPOPDPNDYG": "Age dependency ratio, young (% of working-age population)", "SPPOPGROW": "Population growth (annual %)", "SPPOPTOTL": "Population, total", "SPPOPTOTLFEIN": "Population, female", "SPPOPTOTLFEZS": "Population, female (% of total population)", "SPPOPTOTLMAIN": "Population, male", "SPPOPTOTLMAZS": "Population, male (% of total population)", "SPRURTOTL": "Rural population", "SPRURTOTLZG": "Rural population growth (annual %)", "SPRURTOTLZS": "Rural population (% of total population)", "SPURBGROW": "Urban population growth (annual %)", "SPURBTOTL": "Urban population", "SPURBTOTLINZS": "Urban population (% of total population)", "STINTARVL": "International tourism, number of arrivals", "TGVALTOTLGDZS": "Merchandise trade (% of GDP)", "TMQTYMRCHXDWD": "Import volume index (2000 = 100)", "TMUVIMRCHXDWD": "Import unit value index (2000 = 100)", "TMVALMRCHALZS": "Merchandise imports from economies in the Arab World (% of total merchandise imports)", "TMVALMRCHCDWT": "Merchandise imports (current US$)", "TMVALMRCHHIZS": "Merchandise imports from high-income economies (% of total merchandise imports)", "TMVALMRCHORZS": "Merchandise imports from low- and middle-income economies outside region (% of total merchandise imports)", "TMVALMRCHR1ZS": "Merchandise imports from low- and middle-income economies in East Asia &amp; Pacific (% of total merchandise imports)", "TMVALMRCHR2ZS": "Merchandise imports from low- and middle-income economies in Europe &amp; Central Asia (% of total merchandise imports)", "TMVALMRCHR3ZS": "Merchandise imports from low- and middle-income economies in Latin America &amp; the Caribbean (% of total merchandise imports)", "TMVALMRCHR4ZS": "Merchandise imports from low- and middle-income economies in Middle East &amp; North Africa (% of total merchandise imports)", "TMVALMRCHR5ZS": "Merchandise imports from low- and middle-income economies in South Asia (% of total merchandise imports)", "TMVALMRCHR6ZS": "Merchandise imports from low- and middle-income economies in Sub-Saharan Africa (% of total merchandise imports)", "TMVALMRCHRSZS": "Merchandise imports by the reporting economy, residual (% of total merchandise imports)", "TMVALMRCHWLCD": "Merchandise imports by the reporting economy (current US$)", "TMVALMRCHXDWD": "Import value index (2000 = 100)", "TTPRIMRCHXDWD": "Net barter terms of trade index (2000 = 100)", "TXQTYMRCHXDWD": "Export volume index (2000 = 100)", "TXUVIMRCHXDWD": "Export unit value index (2000 = 100)", "TXVALMRCHALZS": "Merchandise exports to economies in the Arab World (% of total merchandise exports)", "TXVALMRCHCDWT": "Merchandise exports (current US$)", "TXVALMRCHHIZS": "Merchandise exports to high-income economies (% of total merchandise exports)", "TXVALMRCHORZS": "Merchandise exports to low- and middle-income economies outside region (% of total merchandise exports)", "TXVALMRCHR1ZS": "Merchandise exports to low- and middle-income economies in East Asia &amp; Pacific (% of total merchandise exports)", "TXVALMRCHR2ZS": "Merchandise exports to low- and middle-income economies in Europe &amp; Central Asia (% of total merchandise exports)", "TXVALMRCHR3ZS": "Merchandise exports to low- and middle-income economies in Latin America &amp; the Caribbean (% of total merchandise exports)", "TXVALMRCHR4ZS": "Merchandise exports to low- and middle-income economies in Middle East &amp; North Africa (% of total merchandise exports)", "TXVALMRCHR5ZS": "Merchandise exports to low- and middle-income economies in South Asia (% of total merchandise exports)", "TXVALMRCHR6ZS": "Merchandise exports to low- and middle-income economies in Sub-Saharan Africa (% of total merchandise exports)", "TXVALMRCHRSZS": "Merchandise exports by the reporting economy, residual (% of total merchandise exports)", "TXVALMRCHWLCD": "Merchandise exports by the reporting economy (current US$)", "TXVALMRCHXDWD": "Export value index (2000 = 100)"}

3) /api/data GET request: arguments can be given in a key-value fashion

In [7]:
endpoint = "/api/data"
args = {"country": ["Hungary","Belgium"], "series_code": ["ENATMCO2EKT", "AGLNDAGRIK2"]}
args_URI = [ [f"{k}={x}" for x in args[k]] for k in args.keys()]

resp_obj = requests.get(prefix + endpoint + "?" + "&".join(flatten(args_URI)))
resp_obj
Out[7]:
<Response [200]>
In [8]:
pd.read_html(prefix + endpoint + "?" + "&".join(flatten(args_URI)))
Out[8]:
[   Series Code        ENATMCO2EKT        AGLNDAGRIK2
   Country Name Unnamed: 1_level_1 Unnamed: 2_level_1
 0      Hungary          44418.371            52640.0
 1      Belgium              1.500                2.0]

4) /api/data POST request: add data to existing dataset

In [9]:
endpoint = "/api/data"
args = {"country": ["Azmenistan"], "series_code": ["ENATMCO2EKT", "AGLNDAGRIK2"], "value":["1.5", "2"]}
args_URI = [ [f"{k}={x}" for x in args[k]] for k in args.keys()]

resp_obj = requests.post(prefix + endpoint + "?" + "&".join(flatten(args_URI)))
resp_obj
Out[9]:
<Response [200]>
In [10]:
resp_obj.content
Out[10]:
b'{"Error": "Country already exists in the database."}\n'

5) /api/data PUT request: modify existing data

In [11]:
endpoint = "/api/data"
args = {"country": ["Belgium"], "series_code": ["ENATMCO2EKT", "AGLNDAGRIK2"], "value":["1.5", "2"]}
args_URI = [ [f"{k}={x}" for x in args[k]] for k in args.keys()]

resp_obj = requests.put(prefix + endpoint + "?" + "&".join(flatten(args_URI)))
resp_obj
Out[11]:
<Response [200]>
In [12]:
resp_obj.content
Out[12]:
b'{"Message": "Edit succesful."}\n'

Misc) some interesting figures

In [13]:
endpoint = "/api/tsne"
#args = {"country": ["Belgium"], "series_code": ["ENATMCO2EKT", "AGLNDAGRIK2"], "value":["1.5", "2"]}
#args_URI = [ [f"{k}={x}" for x in args[k]] for k in args.keys()]

resp_obj = requests.get(prefix + endpoint) #+ "?" + "&".join(flatten(args_URI)))
resp_obj
Out[13]:
<Response [200]>
In [14]:
from IPython.core.display import display, HTML

#I tried but couldnt re-import the plotly html into jupyter
#From what I understood, this is how it should work:


display(HTML(str(BeautifulSoup(resp_obj.content,"html.parser"))))
In [15]:
endpoint = "/api/pca"
#args = {"country": ["Belgium"], "series_code": ["ENATMCO2EKT", "AGLNDAGRIK2"], "value":["1.5", "2"]}
#args_URI = [ [f"{k}={x}" for x in args[k]] for k in args.keys()]

resp_obj = requests.get(prefix + endpoint) #+ "?" + "&".join(flatten(args_URI)))
resp_obj
Out[15]:
<Response [200]>
In [16]:
display(HTML(str(BeautifulSoup(resp_obj.content,"html.parser"))))